package cn.sytton.taffe.file.entity;

import cn.sytton.taffe.framework.base.entity.BaseUpdatedEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.*;

/**
 * 文件表entity sys_file
 *
 * @author skyrock
 */
@Schema(description = "文件")
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain=true)
@NoArgsConstructor
@TableName("sys_file")
public class FileEntity extends BaseUpdatedEntity {

    @Schema(description = "文件ID")
    @TableId(type = IdType.ASSIGN_ID)
    private String fileId;    // 文件ID 

    @Schema(description = "存储桶")
    @NotNull(message = "存储桶不能为空")
    private String bucketName;    // 存储桶

    @Schema(description = "minio对象名")
    @NotNull(message = "minio对象名不能为空")
    private String objectName;    // minio对象名

    @Schema(description = "文件本名")
    @NotNull(message = "文件本名不能为空")
    private String originName;    // 文件本名 

    @Schema(description = "文件扩展名")
    private String suffix;    // 文件扩展名

    @Schema(description = "文件大小")
    private long size;    // 文件大小 

    //-----以下是关联属性-----

    @Schema(description = "文件地址")
    @TableField(exist = false)
    private String url;

    @Schema(description = "文件公共地址")
    @TableField(exist = false)
    private String publicUrl;
}
